#include "egg.h"
#include "BlocksMatrix.h"

egg::egg(CBlocksMatrix* pParent) : CTetrad(pParent,trungga)
{
}

egg::~egg()
{
}

bool egg::Rotate()
{
	bool bSuccess = false;
	bSuccess = true;
	return bSuccess;
}

bool egg::MoveLeft()
{
	bool bSuccess = false;
	
			bSuccess = true;
		
	return bSuccess;
}

bool egg::MoveRight()
{
	bool bSuccess = false;
	
			bSuccess = true;
		
	return bSuccess;
}

bool egg::MoveDown()
{
	bool bSuccess = false;
	
			m_iYPos++;
			bSuccess = true;
	return bSuccess;
}

void egg::Draw()
{
	int screenX=10, screenY=10; 

	switch (m_Orientation)
	{
	case Rotation0:
	case Rotation180:
		m_pParentMatrix->GetScreenPosFromCell(m_iXPos-1,m_iYPos,screenX,screenY);
		m_pBlockImg->BlitImage(screenX,screenY);
		break;

	case Rotation90:
	case Rotation270:
		m_pParentMatrix->GetScreenPosFromCell(m_iXPos,m_iYPos-1,screenX,screenY);
		m_pBlockImg->BlitImage(screenX,screenY);	
		break;
	}
}

void egg::DrawOnScreen(const TRectanglei& rect)
{
	int XPos = (rect.GetWidth() - 1*BLOCK_WIDTH)/2 + rect.m_Left;
	int YPos = (rect.GetHeight() - 1*BLOCK_HEIGHT)/2 + rect.m_Top;
	m_pBlockImg->BlitImage(XPos,YPos);
}

void egg::FillMatrix()
{
	switch (m_Orientation)
	{
	case Rotation0:
	case Rotation180:
		m_pParentMatrix->FillCell(m_iXPos-1,m_iYPos,m_BlockColor);
		
		break;

	case Rotation90:
	case Rotation270:
		m_pParentMatrix->FillCell(m_iXPos,m_iYPos-1,m_BlockColor);
		break;
	}
}

bool egg::IsValid()
{
	bool bValid = false;
	if (m_pParentMatrix->IsCellFree(m_iXPos-1,m_iYPos) )
	{
		bValid = true;
	}

	return bValid;
}
